print("helloworld")
from main import mydoaconfig
import scipy.fft
import numpy as np
from scipy.linalg import inv, eig, svd
import matplotlib.pyplot as plt
from scipy.signal import hilbert, chirp

class Demo:

    def __init__(self, parameter):
        self.parameter = parameter
    
    def __str__(self):
        return (self.parameter.__str__())
    
    def doaest(self,X):
        print("doaest")
        R=X*X.conj().T
        print(R)

        return 0
    
    def demo(self):
        print(scipy.fft.fft(np.exp(2j * np.pi * np.arange(8) / 8)))
        # Create two random square matrices A and B
        A = np.random.rand(3, 3)
        B = np.random.rand(3, 3)
        # Create a vector x
        x = np.random.rand(3)
        # Demonstrate various operations
        print("Matrix A:\n", A)
        print("Matrix B:\n", B)
        print("Vector x:\n", x)
        # Addition
        C = A + B
        print("\nAddition (A + B):\n", C)
        # Subtraction
        D = A - B
        print("\nSubtraction (A - B):\n", D)
        # Matrix Multiplication
        E = np.dot(A, B)
        print("\nMatrix Multiplication (A * B):\n", E)
        # Element-wise Multiplication (Hadamard product)
        F = np.multiply(A, B)
        print("\nElement-wise Multiplication (A .* B):\n", F)
        # Inversion of matrix A
        if np.linalg.det(A) != 0:  # Check if A is invertible
            A_inv = inv(A)
            print("\nInversion of A:\n", A_inv)
        else:
            print("\nMatrix A is not invertible.")
        # Eigenvalues and eigenvectors of matrix A
        eigenvalues, eigenvectors = eig(A)
        print("\nEigenvalues of A:\n", eigenvalues)
        print("\nEigenvectors of A:\n", eigenvectors)
        # Singular Value Decomposition of matrix A
        U, s, Vt = svd(A, full_matrices=False)
        print("\nSingular values of A:\n", s)
        print("\nLeft singular vectors of A:\n", U)
        print("\nRight singular vectors of A:\n", Vt)
        # Selection
        # Select the first row of matrix A
        first_row = A[0, :]
        print("\nFirst row of A:\n", first_row)
        # Select the second column of matrix A
        second_column = A[:, 1]
        print("\nSecond column of A:\n", second_column)
        # Select a submatrix from A consisting of rows 1 and 2 and columns 1 and 2
        submatrix = A[1:3, 1:3]
        print("\nSubmatrix of A (rows 1 and 2, columns 1 and 2):\n", submatrix)
        
        # Create two random complex matrices A and B
        A = np.random.rand(3, 3) + 1j * np.random.rand(3, 3)
        B = np.random.rand(3, 3) + 1j * np.random.rand(3, 3)
        # Create a random complex vector x
        x = np.random.rand(3) + 1j * np.random.rand(3)
        # Demonstrate various operations
        print("Matrix A:\n", A)
        print("Matrix B:\n", B)
        print("Vector x:\n", x)
        # Addition
        C = A + B
        print("\nAddition (A + B):\n", C)
        # Subtraction
        D = A - B
        print("\nSubtraction (A - B):\n", D)
        # Matrix Multiplication
        E = np.dot(A, B)
        print("\nMatrix Multiplication (A * B):\n", E)
        # Element-wise Multiplication (Hadamard product)
        F = np.multiply(A, B)
        print("\nElement-wise Multiplication (A .* B):\n", F)
        # Inversion of matrix A
        if np.allclose(np.linalg.det(A), 0, atol=1e-8):  # Check if A is invertible
            print("\nMatrix A is not invertible.")
        else:
            A_inv = inv(A)
            print("\nInversion of A:\n", A_inv)
        # Eigenvalues and eigenvectors of matrix A
        eigenvalues, eigenvectors = eig(A)
        print("\nEigenvalues of A:\n", eigenvalues)
        print("\nEigenvectors of A:\n", eigenvectors)
        # Singular Value Decomposition of matrix A
        U, s, Vt = svd(A, full_matrices=False)
        print("\nSingular values of A:\n", s)
        print("\nLeft singular vectors of A:\n", U)
        print("\nRight singular vectors of A:\n", Vt)
        # Selection
        # Select the first row of matrix A
        first_row = A[0, :]
        print("\nFirst row of A:\n", first_row)
        # Select the second column of matrix A
        second_column = A[:, 1]
        print("\nSecond column of A:\n", second_column)
        # Select a submatrix from A consisting of rows 1 and 2 and columns 1 and 2
        submatrix = A[1:3, 1:3]
        print("\nSubmatrix of A (rows 1 and 2, columns 1 and 2):\n", submatrix)

        return 100
    
    

# Example usage:
doaconfig = mydoaconfig("./config.ini")
doaestclass = Demo(doaconfig)
print(doaestclass) 
doaestclass.doaest()

